package com.ruoyi.common.base.biz.service.base;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.base.biz.mapper.BaseMapper;
import com.ruoyi.common.core.domain.BizBaseEntity;
import com.ruoyi.common.utils.paging.PagingUtils;

import java.util.List;

/**
 * BaseServiceImpl
 *
 * @author ZhengJun
 * @since 2023/6/7 21:08
 */
public class BaseServiceImpl<E extends BizBaseEntity, Do extends E, Po extends E, M extends BaseMapper<E, Do, Po>>
        extends ServiceImpl<M, E> implements BaseService<E, Do, Po> {
    @Override
    public PageInfo<Po> pagingPoByDo(Do conditionDo) {
        // 从conditionDo中获取pageDo相关信息
        Page<Do> pageDo = PagingUtils.toPageDo(conditionDo, getOrderColumnMap());
        Page<Po> pagePo = this.getBaseMapper().pagingPoByDo(pageDo, conditionDo);
        return PagingUtils.toPageInfoPo(pagePo);
    }

    @Override
    public List<Po> listPoByDo(Do conditionDo) {
        return this.getBaseMapper().listPoByDo(conditionDo);
    }

    @Override
    public Po getPoByDo(Do conditionDo) {
        return this.getBaseMapper().getPoByDo(conditionDo);
    }

    @Override
    public Po getPoById(Long id) {
        return this.getBaseMapper().getPoById(id);
    }
}
